<template>
  <div id="app">
      <ul>
        <li v-for="(item,ind) in arr" :key="ind"><span>{{item}} </span> <button @click="btn(ind)">删除</button></li>
      </ul>
      <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data(){
    return{
      arr:[1,7,3,5,6,8,20]
    }
  },
  methods:{
    add(){
      this.arr.push(Math.floor(Math.random() * 20))
    },
    btn(index){
      this.arr.splice(index,1)
    }
  }
};
</script>

<style>
</style>
